import { formatDate } from '@/helpers/dateutil';

function showVfDate(date1, date2, date3) {
  const vfFormat = 'MM/DD HH:mm';
  return (
    formatDate(date1, vfFormat) ||
    formatDate(date2, vfFormat) ||
    formatDate(date3, vfFormat)
  );
}

export function transPlanStatus(planStatus) {
  var returnStr = '';
  switch (planStatus) {
    case 3:
      returnStr = '待下发生产';
      break;
    case 6:
      returnStr = '待下发签收';
      break;

    case 7:
      returnStr = '待生产执行';
      break;

    case 11:
      returnStr = '已关闭';
      break;

    case 13:
      returnStr = '退单待确认';
      break;

    case 14:
      returnStr = '退单至PPC';
      break;

    case 18:
      returnStr = '退单至MCC';
      break;

    default:
      break;
  }
  return returnStr;
}

//后序航班
export function transPostflight(task) {
  if (task.TS_TaskPaperType === 'SC') {
    return '';
  } else if (task.TS_TaskPaperType === 'PF') {
    return `${task.VF_FlightID_Next} ${showVfDate(
      task.VF_ATD,
      task.VF_ETD,
      task.VF_STD,
    )} ${task.VF_DepartureAirport}-${task.VF_ArriveAirport}`;
  } else {
    return `${task.VF_FlightID_Next} ${showVfDate(
      task.VF_ATD_Next,
      task.VF_ETD_Next,
      task.VF_STD_Next,
    )} ${task.VF_ArriveAirport}-${task.VF_ArriveAirport_Next}`;
  }
}
//前序航班
export function transPreflight(task) {
  if (task.TS_TaskPaperType === 'PF' || task.TS_TaskPaperType === 'SC') {
    return '';
  } else {
    return `${task.VF_DepartureAirport} ${showVfDate(
      task.VF_ATA,
      task.VF_ETA,
      task.VF_STA,
    )} ${task.VF_DepartureAirport}-${task.VF_ArriveAirport}`;
  }
}

export function transAirport(task) {
  if (task.TS_TaskPaperType === 'PF') {
    return task.VF_DepartureAirport;
  } else if (task.TS_TaskPaperType === 'SC') {
    return task.VF_ArriveAirport;
  } else {
    return task.VF_ArriveAirport;
  }
}
